import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '赛事id',
    align:"center",
    dataIndex: 'saisId_dictText'
   },
   {
    title: '赛事进程id',
    align:"center",
    dataIndex: 'saisjcId_dictText'
   },
   {
    title: '赛区id',
    align:"center",
    dataIndex: 'quyId',
    customRender:({text}) => {
       return  render.renderCategoryTree(text,'C05')
   },
   },
   {
    title: '奖项名称',
    align:"center",
    dataIndex: 'jxName'
   },
   {
    title: '奖品数量',
    align:"center",
    dataIndex: 'jpCount'
   },
   {
    title: '备注',
    align:"center",
    dataIndex: 'remark'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '赛事id',
    field: 'saisId',
    component: 'JDictSelectTag',
    componentProps: ({formActionType, formModel}) => {
      return {
        dictCode:"cdba2_sais,mingc,id",
        onChange: (value) => {
          console.log("saisId: " + value)
          const {updateSchema } = formActionType
          updateSchema([
            {
              field: 'saisjcId',
              componentProps: {dictCode: 'cdba2_saisjc,jincmc,id,sais_id = ' + value}
            }
          ])
        }
      }
    }
  },
	{
      label: "赛事进程id",
      field: 'saisjcId',
      component: 'JDictSelectTag',
      componentProps:{

      },
      //colProps: {span: 6},
 	},
	{
      label: "赛区id",
      field: 'quyId',
      component: 'JCategorySelect',
      componentProps:{
          pcode:"C05",//back和事件未添加，暂时有问题
      },
      //colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '赛事id',
    field: 'saisId',
    component: 'JDictSelectTag',
    componentProps: ({formActionType, formModel}) => {
      return {
        dictCode:"cdba2_sais,mingc,id",
        onChange: (value) => {
          console.log("saisId: " + value)
          const {updateSchema } = formActionType
          updateSchema([
            {
              field: 'saisjcId',
              componentProps: {dictCode: 'cdba2_saisjc,jincmc,id,sais_id = ' + value}
            }
          ])
        }
      }
    }
  },
  {
    label: '赛事进程id',
    field: 'saisjcId',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:""
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入赛事进程id!'},
          ];
     },
  },
  {
    label: '赛区id',
    field: 'quyId',
    component: 'JCategorySelect',
    componentProps:{
       pcode:"C05", //TODO back和事件未添加，暂时有问题
    },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入赛区id!'},
          ];
     },
  },
  {
    label: '奖项名称',
    field: 'jxName',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入奖项名称!'},
          ];
     },
  },
  {
    label: '奖品数量',
    field: 'jpCount',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入奖品数量!'},
                 { pattern: /^-?\d+$/, message: '请输入整数!'},
          ];
     },
  },
  {
    label: '备注',
    field: 'remark',
    component: 'InputTextArea',
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  saisId: {title: '赛事id',order: 0,view: 'list', type: 'string',dictTable: "cdba2_sais", dictCode: 'id', dictText: 'mingc',},
  saisjcId: {title: '赛事进程id',order: 1,view: 'list', type: 'string',},
  quyId: {title: '赛区id',order: 2,view: 'cat_tree', type: 'string',pcode: 'C05',},
  jxName: {title: '奖项名称',order: 3,view: 'text', type: 'string',},
  jpCount: {title: '奖品数量',order: 4,view: 'number', type: 'number',},
  remark: {title: '备注',order: 5,view: 'textarea', type: 'string',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
